package com.yueka.controller;

import com.yueka.pojo.Result;
import com.yueka.service.StudentSystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/studentSystem")
@RestController
public class StudentSystemController {

    @Autowired
    private StudentSystemService studentSystemService;


    @GetMapping("/login")
    public Result login(String phone, String studentName) {
        try {
            return Result.success(studentSystemService.login(phone, studentName));
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }

    @GetMapping("/info")
    public Result info(Integer studentId) {
        try {
            return Result.success(studentSystemService.info(studentId));
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }

    @GetMapping("/courseList")
    public Result courseList(Integer studentId) {
        try {
            return Result.success(studentSystemService.courseList(studentId));
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }

    @GetMapping("/courseDetail")
    public Result courseDetail(Integer courseId) {
        try {
            return Result.success(studentSystemService.courseDetail(courseId));
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }
}
